Skip to content

Remove unchecked Sendable from NotificationListener - #663

Open
fabianfett wants to merge 2 commits into
vapor:mainfrom
fabianfett:ff-remove-unchecked-sendable2
Open

Remove unchecked Sendable from NotificationListener#663
fabianfett wants to merge 2 commits into
vapor:mainfrom
fabianfett:ff-remove-unchecked-sendable2

Conversation

@fabianfett

Copy link
Copy Markdown
Collaborator

Motivation

  • @unchecked Sendable is dangerous

Changes

  • Use NIOLoopBoundBox in NotificationListener to show the compiler what is safe

Result

One instance of @unchecked Sendable less

@fabianfett
fabianfett requested a review from gwynne as a code owner August 12, 2026 10:25
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.24731% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.56%. Comparing base (f92acff) to head (f336324).

Files with missing lines Patch % Lines
Sources/PostgresNIO/New/NotificationListener.swift 89.24% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #663      +/-   ##
==========================================
- Coverage   77.58%   77.56%   -0.03%     
==========================================
  Files         137      137              
  Lines       10668    10702      +34     
==========================================
+ Hits         8277     8301      +24     
- Misses       2391     2401      +10     
Files with missing lines Coverage Δ
Sources/PostgresNIO/New/NotificationListener.swift 89.91% <89.24%> (+2.85%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

switch self.state {
// The state may only be inspected on the EventLoop. If we are deinitialized somewhere else,
// we can't validate that the listener has been used correctly.
guard self.eventLoop.inEventLoop else { return }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it this is something that can happen too easily for an assertion to be safe?

break

@unknown default:
break

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we cancel for unknown termination reasons? Seems like the safer choice IMO.

let id: Int

private var state: State
private let stateBox: NIOLoopBoundBox<State>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a nit, just curiosity—how much overhead does NIOLoopBoundBox impose? My guess is not very much.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly one additional alloc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants